{{extend 'layout.html'}}

<div class="breadcrumbs">
    <a class="breadcrumbs" href="{{=URL(r=request, c='default', f='index')}}" title="Home">Home</a><span
       class="sep"> / </span><b>{{=forum.forum_title}}</b>
    {{if view_info['subscribed_to_forum']:}}<i>[You are currently subscribed to this forum]</i>{{pass}}
</div>

<div class="subnav">
    {{=len(parent_topics)}} Topic(s) Found
    {{if security_info['can_add']:}}
        <span class="sep">|</span>
        <a href="{{=URL(r=request, c='default', f='add_topic', args=[forum.id])}}" title="Add New Topic">Add New Topic</a>
    {{pass}}
    {{if auth.is_logged_in():}}
        |
        {{if view_info['subscribed_to_forum']:}}
            <a href="{{=URL(r=request, c='default', f='forum', args=[forum.id, 0])}}" title="Unsubscribe from Forum">Unsubscribe from Forum</a>
        {{else:}}
            <a href="{{=URL(r=request, c='default', f='forum', args=[forum.id, 1])}}" title="Subscribe to Forum">Subscribe to Forum</a>
        {{pass}}
    {{pass}}
</div>

<div>{{=XML(view_info['pagination_widget'])}}</div>

{{if parent_topics:}}
    <form id="del_topics_form" method="post" action="">
        <fieldset id="del_topics_form_fields">
            <input type="hidden" id="form_submitted" name="form_submitted" value="1" />
            <input type="hidden" id="forum_id" name="forum_id" value="{{=forum.id}}" />

            {{if auth.has_membership(forum_memberships['FORUM_ADMINISTRATOR']):}}
                <div class="bottom-separator">
                    <input type="submit"
                    id="top_del_topics"
                    name="del_topics"
                    onclick="return confirm('WARNING: Removing a parent topic will also remove all of its sibling topcs\n\nPlease Confirm.');"
                    value="Remove Checked Topics" />
                </div>
            {{pass}}

            <table class="bordered" style="width:100%;">
                <thead>
                    <tr class="shadedarker">
                        <th>&nbsp;</th>
                        <th style="text-align:left;">{{=forum.forum_title}}</th>
                        <th>By</th>
                        <th style="width:5%;max-width:5%">Replies</th>
                        <th style="width:5%;max-width:5%">Views</th>
                        <th style="width:20%;max-width:20%;white-space:nowrap;">Last Updated</th>
                    </tr>
                </thead>
                <tbody>
                    {{for row, this_topic in enumerate(parent_topics):}}
                        <tr>
                            <td>
                                {{if auth.has_membership(forum_memberships['FORUM_ADMINISTRATOR']):}}
                                    <input type="checkbox" id="del_topic_{{=this_topic.id}}" name="del_topic_{{=this_topic.id}}" value="{{=this_topic.id}}" />
                                {{else:}}
                                    &nbsp;
                                {{pass}}
                            </td>
                            <td>
                                {{if view_info[this_topic.id]['subscribed_to_topic']:}}<img src="{{=URL(r=request, c='static/images', f='subscribed.gif')}}" alt="[Subscribed to Topic]" class="imgclear" />{{pass}}
                                {{if this_topic.sticky_flag:}}<img src="{{=URL(r=request, c='static/images', f='sticky_topic.gif')}}" alt="[Sticky Topic]" class="imgclear" />{{pass}}
                                {{if this_topic.locked_flag:}}<img src="{{=URL(r=request, c='static/images', f='locked_topic.gif')}}" alt="[Locked Topic]" class="imgclear" />{{pass}}
                                <a href="{{=URL(r=request, c='default', f='topic', args=[this_topic.id])}}" title="" class="linkb">{{=XML(this_topic.title)}}</a>
                                {{if view_info['zfsp_topic_teaser_length']:}}
                                    <br /><span class="small">{{=XML(this_topic.contents[:view_info['zfsp_topic_teaser_length']], sanitize=True)}} ..</span>
                                {{pass}}
                            </td>
                            <td>{{if this_topic.creation_user_id:}}<a href="{{=URL(r=request, c='pm', f='message_new', args=[this_topic.creation_user_id])}}" title="">{{=forumhelper.get_display_name(this_topic.creation_user_id, 'Anonymous User')}}</a>{{else:}}Anonymous User{{pass}}</td>
                            <td>{{=topic_replies_info[this_topic.id]}}</td>
                            <td>{{=this_topic.hits}}</td>
                            <td>
                                <div class="{{if (request.now - this_topic.modifying_date).days == 0:}}important{{else:}}small{{pass}}">
                                    <span class="small">
                                        {{=this_topic.modifying_date.strftime(str(T('%b %d, %Y - %I:%M %p')))}}
                                    </span>
                                    <br /><span class="small">By</span>
                                    {{if not this_topic.modifying_user_id:}}
                                        <b class="small">Anonymous User</b>
                                    {{else:}}
                                        {{if auth.is_logged_in():}}
                                            <a href="{{=URL(r=request, c='pm', f='message_new', args=[this_topic.modifying_user_id])}}"
                                               title=""
                                               class="{{if (request.now - this_topic.modifying_date).days == 0:}}smallb-new{{else:}}smallb{{pass}}">{{=forumhelper.get_member_property('zfmp_display_name', this_topic.modifying_user_id, 'user_%s' % (this_topic.modifying_user_id))}}</a>
                                        {{else:}}
                                            <b class="small">{{=forumhelper.get_member_property('zfmp_display_name', this_topic.modifying_user_id, 'user_%s' % (this_topic.modifying_user_id))}}</b>
                                        {{pass}}
                                    {{pass}}
                                </div>
                            </td>
                        </tr>
                    {{pass}}
                </tbody>
            </table>

            {{if auth.has_membership(forum_memberships['FORUM_ADMINISTRATOR']):}}
                <div class="top-separator">
                    <input type="submit"
                    id="bottom_del_topics"
                    name="del_topics"
                    onclick="return confirm('WARNING: Removing a parent topic will also remove all of its sibling topcs\n\nPlease Confirm.');"
                    value="Remove Checked Topics" />
                </div>
            {{pass}}

        </fieldset>
    </form>
{{else:}}
    <p class="warning">No topics found in this forum.</p>
{{pass}}
